package com.example.addressbook.controller;

import com.example.addressbook.entities.Tel;
import com.example.addressbook.service.TelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("tel")
public class TelController {

    @Autowired
    TelService telService;
//新建号码
    @RequestMapping("/new")
    public String new_tel(Model model){
        Tel tel =new Tel();
        model.addAttribute("TelePhone",tel);
        return "new-tels";
    }

//保存新建号码
    @PostMapping("/save")
    public String save_tels(Model model , Tel tels){
        telService.save(tels);
        return "redirect:/tel/new";
    }


}
